package com.chima.dao;
import java.util.List;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.chima.domain.TastCenterOperationcount;
import com.chima.domain.Taskcenterbouns;
import com.chima.domain.Taskcenterbounsstock;
import com.chima.domain.TastCentercoffe;
public class TastCenterDao extends HibernateDaoSupport {
	
	
	//查询操作项
	public TastCentercoffe findTastCentercoffeById( int id ) {
		Session session=this.getSession();
		TastCentercoffe r = (TastCentercoffe) session.createQuery("from TastCentercoffe s where s.id = ?").setParameter(0, id).uniqueResult();
		super.releaseSession(session);
		return r;
	}
	public TastCentercoffe findTastCentercoffeByNameAndDept(int dept, String name ) {
		Session session=this.getSession();
		TastCentercoffe r = (TastCentercoffe) session.createQuery("from Supplyroomcoffe s where s.operationName = ? and s.department.id=? ").setParameter(0, name).setParameter(1, dept).uniqueResult();
		super.releaseSession(session);
		return r;
	}
	
    //查询奖金存量
	public Taskcenterbounsstock findTaskcenterbounsstockByDateAndDeptId( String date , int deptId ) {
		Session session=this.getSession();
		Taskcenterbounsstock r = (Taskcenterbounsstock)session.createQuery("from Taskcenterbounsstock s where s.date =?  and s.department.id=?").setParameter(0, date).setParameter(1, deptId).uniqueResult();
		super.releaseSession(session);
		return r;
	}
	
	public void saveTaskcenterbouns(Taskcenterbouns taskcenterbouns) {
		this.getHibernateTemplate().save(taskcenterbouns);
	}
	
	public void updateTaskcenterbouns(Taskcenterbouns taskcenterbouns) {
		this.getHibernateTemplate().update(taskcenterbouns);
	}
	
		public List<TastCenterOperationcount>  findMedicalcountByDate( String date,int dept) {
			Session session=this.getSession();
			List<TastCenterOperationcount> s = session.createQuery("from Medicalcount s where s.date= ? and s.department.id=? ").setParameter(0, date).setParameter(1, dept).list();
			super.releaseSession(session);
			return s;
		}
		public Taskcenterbouns findTaskcenterbounsByDateAndDeptId( String date,int deptId ) {
			Session session=this.getSession();
			Taskcenterbouns r = (Taskcenterbouns)session.createQuery("from Taskcenterbouns s where s.date =?  and s.department.id=?").setParameter(0, date).setParameter(1, deptId).uniqueResult();
			super.releaseSession(session);
			return r;
		}
		public void updateTastCenterOperationcount(TastCenterOperationcount tastCenterOperationcount) {
			this.getHibernateTemplate().update(tastCenterOperationcount);
		}
		public void saveTastCenterOperationcount(TastCenterOperationcount tastCenterOperationcount) {
			this.getHibernateTemplate().save(tastCenterOperationcount);
		}
		
}
